/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package elementsDefense.towers;

import elementsDefense.towers.projectils.IceBlast;
import elementsDefense.towers.projectils.Projectil;
import com.jme3.asset.AssetManager;
import com.jme3.effect.ParticleEmitter;
import com.jme3.effect.ParticleMesh;
import com.jme3.material.Material;
import com.jme3.math.ColorRGBA;
import com.jme3.math.Vector3f;
import com.jme3.scene.Geometry;
import com.jme3.scene.Node;
import com.jme3.scene.Spatial;
import com.jme3.scene.shape.Box;
import elementsDefense.enemies.BasicEnemy;
import elementsDefense.enemies.HoverControl;

/**
 *
 * @author Ricardo
 */
public class IceTower extends Tower {
    static Material matTower;
    
    Spatial geom2;
    Projectil attack;
    
    
    public void build(AssetManager assetManager, Node node, Vector3f location){
        super.build(assetManager, node, location);
        if(matTower==null){
            matTower = new Material(assetManager, "Common/MatDefs/Misc/Unshaded.j3md");
            matTower.setTexture("ColorMap", assetManager.loadTexture("Textures/tower_ice.jpg"));
        }
        geom = assetManager.loadModel("Models/tower_ice.j3o");
//        geom.rotate(0, FastMath.HALF_PI, 0);
        geom.setMaterial(matTower);
        node.attachChild(geom);
        this.fireLocation = new Vector3f(location).add(0, 0.98f, 0);
        geom.setLocalTranslation(location);
        
        searchAndDestroy = new SearchAndDestroyControl(2, 3f, 0f, this);
        geom.addControl(searchAndDestroy);
        
        
        geom2 = assetManager.loadModel("Models/iceCrystal.j3o");
        geom2.setMaterial(matTower);
        node.attachChild(geom2);
        geom2.setLocalTranslation(fireLocation);
        geom2.addControl(new HoverControl(fireLocation.y, 0.1f, 5));
        
        attack = new IceBlast(assetManager, node, this);
    }

    void prepareToFire(BasicEnemy enemy, float animPhase){
        
    }
    
    void fire(BasicEnemy enemy){
        //fire projectil
        attack.shootAt(enemy);
    }

    @Override
    int getCost() {
        return 30;
    }
  
}
